<template>
  <el-form :model="Lost" label-width="80px" >
    <el-form-item label="编号">
      <el-input v-model="Lost.lost_id" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="客户"> 
      <el-input v-model="Lost.company.com_name" :disabled="true"   ></el-input>
    </el-form-item>

    <el-form-item label="客户经理">
      <el-input v-model="Lost.users.user_name" :disabled="true" ></el-input>
    </el-form-item>
    <el-form-item label="上单时间">
      <el-input v-model="Lost.lost_lasttime" :disabled="true" ></el-input>
    </el-form-item>
     <el-form-item label="确认流失时间" :required="tag2">
    <el-date-picker
      v-model="Lost.lost_date"
      type="datetime"
      placeholder="选择日期时间"
       :disabled="tag1"
      >
     
    </el-date-picker>
    </el-form-item>

    <el-form-item label="暂缓措施"  >
      <el-input v-model="Lost.lost_delay" :disabled="true" ></el-input>
    </el-form-item>

    <el-form-item label="状态" prop="lost_status" :required="tag2">
      <el-radio-group v-model="Lost.lost_status">
        <el-radio :label="2" :disabled="tag1" >确认流失</el-radio>
      </el-radio-group>
    </el-form-item>

    <el-form-item   label="流失原因" :required="tag2" >
      <el-input v-model="Lost.lost_reason" :disabled="tag1"></el-input>
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="onSubmit" v-if="tag2">保存</el-button>
      <el-button type="info" @click="back">返回</el-button>
    </el-form-item>
  </el-form>
</template>



<style>
/* .el-input {
  background: #f0f9eb;
} */
</style>

<script>
export default {
  data() {
    return {
      Lost: {
        lost_id: '',
        lost_status: '',
        lost_delay:'',
        lost_reason: '',
        lost_date:''
      },
      tag1:false,
      tag2:true,

    };
  },
  methods: {
    onSubmit() {
      if(this.Lost.lost_date!=null&&this.Lost.lost_reason!=null&&this.Lost.lost_status==2){
      this.$axios
      .post("/updateByPrimaryKeySelective",this.Lost)
      .then((res)=>{
        alert(res.data.message);
        this.$router.push("/CustomerLost");
      })
      .catch((error)=>{ alert(res.data.message);});
     // console.log("submit!");
    }else{
      alert("必填项必须填写")
    }
    },
    back(){
       this.$router.push("/CustomerLost");
    } 
 
  },
  mounted() {
   //获得存的值
    var lost_id = sessionStorage.getItem("lost_id");
    this.$axios
      .get("/selectByid/" + lost_id)
      .then((res) => {
        this.Lost = res.data.data;
        this.Lost.lost_status=res.data.data.lost_status;
        if(this.Lost.lost_status==2){
          this.tag1=true;
          this.tag2=false;
        }
        
      })
      .catch((error) => {});
  },
};
</script>